// ~~/server/api/auth/logout.post.ts
import { TokenService } from '~~/server/utils/tokens'

export default defineEventHandler(async (event) => {
  const refreshToken = getCookie(event, 'refreshToken')

  if (refreshToken) {
    await TokenService.revokeRefreshToken(refreshToken)
  }

  deleteCookie(event, 'accessToken')
  deleteCookie(event, 'refreshToken')

  return {
    message: '退出登录成功'
  }
})
